import serial

wifiser = serial.Serial()
wifiser.port = "COM9"
wifiser.baudrate = 115200
wifiser.timeout = 1
wifiser.open()

arduinoser = serial.Serial()
arduinoser.port = "COM7"
arduinoser.baudrate = 9600
arduinoser.timeout = 0.05
arduinoser.open()

while True:
    c = wifiser.read_until(expected="\n")
    if len(c) > 0:
        try:
            print("[wifi to arduino]", c.decode(), end="$\n", sep="")
        except UnicodeDecodeError:
            pass
        arduinoser.write(c)
    line = arduinoser.read_until(expected="\n")
    if len(line) > 0:
        try:
            print("[arduino to wifi]", line.decode(), end="$\n", sep="")
        except UnicodeDecodeError:
            pass
        wifiser.write(line)




